﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Admin-One-Column.master"
    AutoEventWireup="true" CodeBehind="QuanLiHoaDon.aspx.cs" Inherits="BookStore.admin.QuanLiHoaDon" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BreadcrumbsContent" runat="server">
<h1>Quản Lí Hóa Đơn</h1>
<br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainColumnContent" runat="server">
    Nhấn vào mã hóa đơn để chỉnh sửa được nhiều thông tin hơn
    <br />
    <br />
    <div id="admin-table">
        <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            DataKeyNames="MaHD" DataSourceID="SqlDataSource1" PageSize="5" 
            OnRowDataBound="GridView2_RowDataBound" PagerStyle-CssClass="pagination" 
            CellPadding="4" ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle CssClass="alt-row" BackColor="White" />
            <Columns>
                <asp:TemplateField HeaderText="Mã" SortExpression="MaHD">
                    <EditItemTemplate>
                        <asp:TextBox CssClass="input-text" ID="TextBox7" runat="server" Text='<%# Bind("MaHD") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "./HoaDon.aspx?MaHD=" + Eval("MaHD") %>'
                            runat="server" Text='<%# Bind("MaHD") %>'>HyperLink</asp:HyperLink>
                    </ItemTemplate>
                    <ItemStyle Width="35px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tên Khách Hàng" SortExpression="MaKH">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="KH_DS" SelectedValue='<%# Bind("MaKH") %>'
                            DataTextField="TenKhachHang" DataValueField="MaKhachHang">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="KH_DS" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:BookStoreConnectionString %>" 
                            SelectCommand="SELECT [MaKhachHang], [TenKhachHang] FROM [KhachHang]">
                        </asp:SqlDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="MaKH" runat="server" Text='<%# Bind("MaKH") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Địa Chỉ HD" SortExpression="DiaChiHoaDon">
                    <EditItemTemplate>
                        <asp:TextBox CssClass="input-text" ID="TextBox9" runat="server" Text='<%# Bind("DiaChiHoaDon") %>'
                            TextMode="MultiLine"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("DiaChiHoaDon") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Địa Chỉ Giao Hàng" SortExpression="DiaChiGiaoHang">
                    <EditItemTemplate>
                        <asp:TextBox CssClass="input-text" ID="TextBox6" runat="server" Text='<%# Bind("DiaChiGiaoHang") %>'
                            TextMode="MultiLine"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("DiaChiGiaoHang") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="140px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Số ĐT" SortExpression="SoDT">
                    <EditItemTemplate>
                        <asp:TextBox CssClass="input-text" ID="TextBox3" runat="server" Text='<%# Bind("SoDT") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("SoDT") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="100px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ngày Tháng" SortExpression="NgayThang">
                    <EditItemTemplate>
                        <asp:TextBox CssClass="input-text" ID="TextBox4" runat="server" Text='<%# Bind("NgayThang") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("NgayThang") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="100px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Trạng Thái">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" SelectedValue='<%# Bind("TrangThai") %>' runat="server">
                            <asp:ListItem Value="0">Chưa giao hàng</asp:ListItem>
                            <asp:ListItem Value="1">Đã Giao</asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList1" SelectedValue='<%# Bind("TrangThai") %>' runat="server"
                            Enabled="false">
                            <asp:ListItem Value="0">Chưa giao hàng</asp:ListItem>
                            <asp:ListItem Value="1">Đã Giao</asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>
                    <ItemStyle Width="90px" />
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                            Text=""><img alt="Delete" src="../images/check.png"></asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text=""><img alt="Delete" src="../images/cross.png"></asp:LinkButton>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                            Text=""><img alt="Edit" src="../images/pencil.png"></asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                            Text=""><img alt="Delete" src="../images/cross.png"></asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle Width="45px" />
                </asp:TemplateField>
            </Columns>
            <EditRowStyle CssClass="align-top" BackColor="#7C6F57" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <PagerStyle CssClass="pagination" BackColor="#666666" ForeColor="White" 
                HorizontalAlign="Center" />
            <RowStyle BackColor="#E3EAEB" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F8FAFA" />
            <SortedAscendingHeaderStyle BackColor="#246B61" />
            <SortedDescendingCellStyle BackColor="#D4DFE1" />
            <SortedDescendingHeaderStyle BackColor="#15524A" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
            DeleteCommand="DELETE FROM [HoaDon] WHERE [MaHD] = @MaHD" InsertCommand="INSERT INTO [HoaDon] ([MaKH], [DiaChiHoaDon], [DiaChiGiaoHang], [SoDT], [NgayThang], [TrangThai]) VALUES (@MaKH, @DiaChiHoaDon, @DiaChiGiaoHang, @SoDT, @NgayThang, @TrangThai)"
            ProviderName="<%$ ConnectionStrings:ApplicationServices.ProviderName %>" SelectCommand="SELECT [MaHD], [MaKH], [DiaChiHoaDon], [DiaChiGiaoHang], [SoDT], [NgayThang], [TrangThai] FROM [HoaDon]"
            UpdateCommand="UPDATE [HoaDon] SET [MaKH] = @MaKH, [DiaChiHoaDon] = @DiaChiHoaDon, [DiaChiGiaoHang] = @DiaChiGiaoHang, [SoDT] = @SoDT, [NgayThang] = @NgayThang, [TrangThai] = @TrangThai WHERE [MaHD] = @MaHD">
            <DeleteParameters>
                <asp:Parameter Name="MaHD" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="MaKH" Type="Int32" />
                <asp:Parameter Name="DiaChiHoaDon" Type="String" />
                <asp:Parameter Name="DiaChiGiaoHang" Type="String" />
                <asp:Parameter Name="SoDT" Type="String" />
                <asp:Parameter Name="NgayThang" Type="DateTime" />
                <asp:Parameter Name="TrangThai" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="MaKH" Type="Int32" />
                <asp:Parameter Name="DiaChiHoaDon" Type="String" />
                <asp:Parameter Name="DiaChiGiaoHang" Type="String" />
                <asp:Parameter Name="SoDT" Type="String" />
                <asp:Parameter Name="NgayThang" Type="DateTime" />
                <asp:Parameter Name="TrangThai" Type="Int32" />
                <asp:Parameter Name="MaHD" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
</asp:Content>
